<?php

	/**
	 * @see Bike_Js_VarPart
	 */
	require_once 'Bike/Js/VarPart.php';
	
	
	class Bike_Js_VarPart_Expression extends Bike_Js_VarPart
	{
		public function _toString()
		{
			$args = $this->getArgs();
			$str = (sizeof($args) ? array_shift($args) : '');
			$expression = parent::_toString();
			$exLen = strlen($expression);
			if(substr($str, 0, $exLen) == $expression)
			{				return (string) $str;
			}
			return (string) $expression.(($str) ? ' '.$str : '');
		}

		protected function getArgs()
		{
			$args = array();
			foreach($this->getSettings() as $key => $value)
			{
				//$args[$key] = $this->jsonEncode($this->_prepareValue($value));
				$args[$key] = $this->_prepareValue($value);
			}
			return $args;
		}
		
		public function getVarCaching()
		{
			return False;
		}
	}
